/**************************************************************************

Game Editor - The Cross Platform Game Creation Tool
Copyright (C) 2009  Makslane Araujo Rodrigues, http://game-editor.com

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

If GPL v3 does not work for you, we offer a "non-GPL" license 
More info at http://game-editor.com/License
Be a Game Editor developer: http://game-editor.com/Sharing_Software_Revenues_in_Open_Source

***************************************************************************/


/////////////////////////////////////////////////////////////////////////////
// Name:        MainFrame.h
// Purpose:     
// Author:      
// Modified by: 
// Created:     01/08/06 14:25:46
// RCS-ID:      
// Copyright:   
// Licence:     
/////////////////////////////////////////////////////////////////////////////


#ifndef __MAINFRAME_H__
#define __MAINFRAME_H__

//#include "wx/aui/aui.h"

////@begin includes
#include "wx/xrc/xmlres.h"
#include "wx/frame.h"
#include "wx/toolbar.h"
#include "wx/docview.h"
////@end includes

#include <wx/ifm/ifm.h>




/*!
 * Control identifiers
 */

////@begin control identifiers
#define ID_FRAME 10000
#define SYMBOL_WXMAINFRAME_STYLE wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxMINIMIZE_BOX|wxMAXIMIZE_BOX|wxCLOSE_BOX
#define SYMBOL_WXMAINFRAME_TITLE _("Oryx")
#define SYMBOL_WXMAINFRAME_IDNAME ID_FRAME
#define SYMBOL_WXMAINFRAME_SIZE wxSize(800, 600)
#define SYMBOL_WXMAINFRAME_POSITION wxDefaultPosition
////@end control identifiers

/*!
 * Compatibility
 */

#ifndef wxCLOSE_BOX
#define wxCLOSE_BOX 0x1000
#endif
#ifndef wxFIXED_MINSIZE
#define wxFIXED_MINSIZE 0
#endif

WX_DECLARE_HASH_MAP(int, wxWindow*, wxIntegerHash, wxIntegerEqual, wxWindowMap);
WX_DECLARE_HASH_MAP(int, wxString, wxIntegerHash, wxIntegerEqual, wxIntStringMap);

/*!
 * wxMainFrame class declaration
 */



class MainFrame : public wxFrame
{
	DECLARE_CLASS( MainFrame )
	DECLARE_EVENT_TABLE()

public:
	MainFrame( );
	MainFrame( wxString _applicationDir, wxWindowID id = SYMBOL_WXMAINFRAME_IDNAME, const wxString& caption = SYMBOL_WXMAINFRAME_TITLE, const wxPoint& pos = SYMBOL_WXMAINFRAME_POSITION, const wxSize& size = SYMBOL_WXMAINFRAME_SIZE, long style = SYMBOL_WXMAINFRAME_STYLE );

	virtual ~MainFrame();

	bool Create( wxWindow* parent, wxWindowID id = SYMBOL_WXMAINFRAME_IDNAME, const wxString& caption = SYMBOL_WXMAINFRAME_TITLE, const wxPoint& pos = SYMBOL_WXMAINFRAME_POSITION, const wxSize& size = SYMBOL_WXMAINFRAME_SIZE, long style = SYMBOL_WXMAINFRAME_STYLE );

	/// Creates the controls and sizers
	void CreateControls();


	////@begin wxMainFrame event handler declarations
	/// wxEVT_CLOSE_WINDOW event handler for ID_FRAME
	void OnCloseWindow( wxCloseEvent& event );

	/// wxEVT_ERASE_BACKGROUND event handler for ID_FRAME
	void OnEraseBackground( wxEraseEvent& event );

	/// wxEVT_COMMAND_MENU_SELECTED event handler for ID_MENU_NEW
	void OnMenuNewClick( wxCommandEvent& event );

	/// wxEVT_COMMAND_MENU_SELECTED event handler for ID_MENU_OPEN
	void OnMenuOpenClick( wxCommandEvent& event );

	/// wxEVT_COMMAND_MENU_SELECTED event handler for ID_MENU_EXIT
	void OnMenuExitClick( wxCommandEvent& event );

	/// wxEVT_COMMAND_MENU_SELECTED event handler for ID_MENU_TITLE_BAR
	void OnMenuTitleBarClick( wxCommandEvent& event );

	/// wxEVT_COMMAND_MENU_SELECTED event handler for ID_MENU_LAYOUT_RESET
	void OnMenuLayoutResetClick( wxCommandEvent& event );

	/// wxEVT_COMMAND_MENU_SELECTED event handler for ID_GAME_MODE
	void OnGameModeClick( wxCommandEvent& event );

	/// wxEVT_COMMAND_MENU_SELECTED event handler for ID_NEW_GAMEOBJECT
	void OnGameObjectClick( wxCommandEvent& event );

	/// wxEVT_COMMAND_MENU_SELECTED event handler for ID_MENU_MRU
	void OnMRUFile( wxCommandEvent& event );

	////@end wxMainFrame event handler declarations

	void OnMove(wxMoveEvent & event);
	void OnSize(wxSizeEvent & event);
	void OnIconize(wxIconizeEvent & event);
	void OnMaximize(wxMaximizeEvent & event);

	////@begin wxMainFrame member function declarations

	/// Retrieves bitmap resources
	wxBitmap GetBitmapResource( const wxString& name );

	/// Retrieves icon resources
	wxIcon GetIconResource( const wxString& name );
	////@end wxMainFrame member function declarations

	/// Should we show tooltips?
	static bool ShowToolTips();

	////@begin wxMainFrame member variables
	////@end wxMainFrame member variables


	void OnActivate(wxActivateEvent& event);

	void OnMenuOpen(wxMenuEvent &event);
	void OnMenuPanel(wxCommandEvent &event);
	void OnMenuLoadLayout(wxCommandEvent &event);

	/********** oryx
	void OnMenuLayoutSaveClick( wxCommandEvent& event );
	void OnMenuLayoutSaveAsClick( wxCommandEvent& event );
	void OnMenuLayoutDeleteClick( wxCommandEvent& event );
	void OnMenuLayoutRestoreClick( wxCommandEvent& event );
	***********/
	void OnLayoutState(wxLayoutStateEvent& event);

	void OnBehaviorBlockSelected( wxCommandEvent &event );

	void OnDropFiles(wxDropFilesEvent & event);



	static MainFrame *Get() {return mainFrame;}
	wxIFMLayoutControl *GetLayoutControl() {return layoutControl;}
	wxPanel *GetRootPanel() {return m_root_panel;}

	void AddLayout(wxString name);
	void RemoveLayout(wxString name);

	bool Show(bool show = true);
	void HidePanels();
	

	const wxString& getApplicationDir() {return applicationDir;}

private:
	void Setup_wxIFM();
	void AppendPanelToMenu(wxWindow *window, wxString &name);
	void AppendLayoutToMenu(wxString name);
	void RemoveLayoutFromMenu(wxString name);
	void SetupMRU();



	wxInterfaceManager *m_ifm;
	wxPanel *m_root_panel;
	wxWindowMap m_panels;
	wxIntStringMap m_layouts;

	/*** oryx
	wxGedStatusBar* statusBar;
	***/

	wxIFMLayoutControl *layoutControl;

	wxString applicationDir;
	wxFileHistory mru;

	bool bMaximized;

	static MainFrame *mainFrame;
};


#endif // __MAINFRAME_H__